package proxy02;

import java.util.Date;

/**
 * ClassName: LaoWangProxy
 * Package: proxy02
 * Description:
 *
 * @Author 刘英杰
 * @Create 2025/2/2 16:15
 * @Version 1.0
 */
public class LaoWangProxy implements OneDay {

    private LaoWang laoWang;

    public LaoWangProxy(LaoWang laoWang) {
        this.laoWang = laoWang;
    }

    @Override
    public void eat() {
        long startTime = new Date().getTime();

        laoWang.eat();

        long endTime = new Date().getTime();
        System.out.println("该行为需要的时间:" + (endTime - startTime));
    }

    @Override
    public void play() {
        long startTime = new Date().getTime();

        laoWang.play();

        long endTime = new Date().getTime();
        System.out.println("玩游戏需要的时间:"+ (endTime-startTime));
    }

    @Override
    public void sleep() {
        long startTime = new Date().getTime();

        laoWang.sleep();

        long endTime = new Date().getTime();
        System.out.println("睡觉需要的时间:"+ (endTime-startTime));
    }
}
